--光赐于苦
local guangciyuku = fk.CreateSkill {
    name = "mcdh_guangciyuku",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

guangciyuku:addEffect(fk.CardUseFinished,{
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) and player:getMark("mcdh_ammo") >0  then
            return data.card.type == Card.TypeEquip and table.every(player.room.alive_players, function(p) return not p.dying end)
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        lib.LoseAmmo(player,player,1,self.name)

        room:damage({
            from = player,
            to = data.from,
            damage = 1,
            skillName = self.name,
        })
        local mark = player:getTableMark("#mcdh_guangciyuku")
        table.insertIfNeed(mark,data.from.id)
        room:setPlayerMark(player,"#mcdh_guangciyuku",mark)
    end
})

guangciyuku:addEffect(fk.AfterCardsMove,{
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) and player:getMark("mcdh_ammo") >0  then
                for _, move in ipairs(data) do
                    if move.moveReason == fk.ReasonDiscard then
                        for _, info in ipairs(move.moveInfo) do
                            if Fk:getCardById(info.cardId).type == Card.TypeEquip then
                                self.cost_data = move.proposer
                                return true
                            end
                        end
                    end
                end
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        lib.LoseAmmo(player,player,1,self.name)

        local to = self.cost_data
        room:damage({
            from = player,
            to = to,
            damage = 1,
            skillName = self.name,
        })
        local mark = player:getTableMark("#mcdh_guangciyuku")
        table.insertIfNeed(mark,to.id)
        room:setPlayerMark(player,"#mcdh_guangciyuku",mark)
    end
})

Fk:loadTranslationTable{
    ["mcdh_guangciyuku"] = "光赐于苦",
    [":mcdh_guangciyuku"] = "装填技(1)，当一名角色使用装备牌,或弃置一名角色的装备牌后,若没有角色处于濒死状态,你可以对其造成1点伤害。",
}
return guangciyuku